/***

Program Code: "Prostitution or Marriage? Evidence from the Nordic Model" (Huasheng Gao, Vanya Petrova & Mengfan Yin)
Date: this version: 2025/6/21
STATA version: 18.0

***/


use "FinalSample.dta",clear

***Dummy for pre and post distance from policy year***
gen distance=year-policy_year
tab distance, missing
gen distance1=distance
gen distance2=distance

replace distance1=-10 if distance1<-10 & distance1!=.
replace distance1=10 if distance1>10 & distance1!=.
replace distance2=5 if distance2>5 & distance2!=.

forvalues i=1/10 { 
gen d_`i'=0 
replace d_`i'=treated if treated==1 & distance1== -`i'
}
forvalues i=0/10 { 
gen d`i'=0 
replace d`i'=treated if treated==1 & distance1== `i'
}

forvalues i=1/5 { 
gen f_`i'=0 
replace f_`i'=treated if treated==1 & distance2== -`i'
}
forvalues i=0/5 { 
gen f`i'=0 
replace f`i'=treated if treated==1 & distance2== `i'
}

**************************************************************
****** TABLE 1(B): Summary Statistics ******
**************************************************************
local v marriagerate divorceper100 marriagerate_f30under marriagerate_f30over marriagerate_m30under marriagerate_m30over marriagerate_fsingle marriagerate_fnonsingle marriagerate_msingle marriagerate_mnonsingle GDPCapita populationGRT sexratio1564 

logout,save ("table1") word replace: ///
	tabstat `v', s(N mean sd p25 p50 p75) format(%12.2f) c(s) 
	
	
****************************************************************************
* Table 2: Effect of the Nordic Model on Marriage and Divorce
****************************************************************************
xi:reghdfe marriagerate nordic ,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic ,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table2.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 2:  Effect of the Nordic Model on Marriage and Divorce})	  
eststo clear 	


****************************************************************************
* Table 3: Testing for Pretreatment Trends and Reversals
****************************************************************************
xi:reghdfe marriagerate f_5 f_4 f_3 f_2 f_1 f0 f1 f2 f3 f4 f5 GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 f_5 f_4 f_3 f_2 f_1 f0 f1 f2 f3 f4 f5 GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table3.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 3:  Testing for Pretreatment Trends and Reversals})	  
eststo clear 


****************************************************************************
* Table 4: Marriage Rates by Age Group
****************************************************************************
xi:reghdfe marriagerate_m30under nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_m30over nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_f30under nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_f30over nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table4.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 4: Marriage Rates by Age Group})	  
eststo clear 


****************************************************************************
* Table 5: Marriage Rate by Previous Marital Status
****************************************************************************
xi:reghdfe marriagerate_msingle nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_mnonsingle nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_fsingle nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate_fnonsingle nordic GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table5.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 5:  Marriage Rate by Previous Marital Status})	  
eststo clear 


****************************************************************************
* Table 6: Heterogeneous Treatment Effects: Female Socioeconomic Status
****************************************************************************
xi:reghdfe marriagerate nordic##highmean_GPG_under35 GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate nordic##highmean_PorvGap GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic##highmean_GPG_under35 GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic##highmean_PorvGap GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table6.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 6:  Heterogeneous Treatment Effects: Female Socioeconomic Status})	  
eststo clear


****************************************************************************
* Table 7: Heterogeneous Treatment Effects: Cohabitation
***************************************************************************
xi:reghdfe marriagerate nordic##unilateraldummy GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate nordic##cohab_regulation GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe marriagerate nordic##highstrongmarriage GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

xi:reghdfe divorceper100 nordic##unilateraldummy GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic##cohab_regulation GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo
xi:reghdfe divorceper100 nordic##highstrongmarriage GDPCapita populationGRT sexratio1564,absorb(country year) vce(cluster country)
eststo

esttab using "table7.rtf",  ar2 b(3) starlevels(* 0.10 ** 0.05 *** 0.01) ///
          replace nogap label nodepvars  ///
          title({\i Table 7:  heterogeneity cohabitation})	  
eststo clear 


****************************************************************************
* Figure 1: Dynamic Effects of the Nordic Model on Marriage and Divorce
****************************************************************************
reg marriagerate d_10 d_9 d_8 d_7 d_6 d_5 d_4 d_3 d_2 d_1 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 GDPCapita populationGRT sexratio1564 i.year i.countryID, robust cluster(country)
event_plot, default_look stub_lag(d#) stub_lead(d_#) together graph_opt(xtitle("Periods since the event") ytitle("OLS coefficients") xlabel(-10(1)10)) alpha(0.1) trimlag(10) trimlead(10)
graph export "figure1_a.png", as(png) name("Graph")

reg divorceper100 d_10 d_9 d_8 d_7 d_6 d_5 d_4 d_3 d_2 d_1 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 GDPCapita populationGRT sexratio1564 i.year i.countryID, robust cluster(country)
event_plot, default_look stub_lag(d#) stub_lead(d_#) together graph_opt(xtitle("Periods since the event") ytitle("OLS coefficients") xlabel(-10(1)10)) alpha(0.1) trimlag(10) trimlead(10)
graph export "figure1_b.png", as(png) name("Graph")


